package zw_1001_1100.zw_1009_十进制整数的反码;

class Solution {
    public static void main(String[] args) {
        int n = 10;
        int complement = bitwiseComplement(n);
        System.out.println(complement);
    }


    public static int bitwiseComplement(int n) {
        if (n == 0) return 1;
        int k = 0;
        while (1 << k <= n) {
            k++;
        }
        return (1 << k) - 1 - n;
    }
}